#!/bin/bash

DUMP=/usr/bin/mysqldump
BACKUPDIR=/export/mysql_backup

DATE=`/bin/date +%Y%m%d`
GZIP=/bin/gzip

OPT="--all-databases"
#OPT="--all-databases --flush-logs"
USER=root
#PASS=um1O3@l.
PASS=sun123


umask 007

$DUMP $OPT -u${USER} -p${PASS} | $GZIP -c > ${BACKUPDIR}/mysql_backup_${DATE}.sql.gz
#/usr/bin/mysql  -uroot -psenha1 -e"reset master"
/usr/bin/mysql -uroot -p${PASS} -e"PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);"
